/**
 * Created by jiangtao on 2017/5/26.
 */
import reqwest from 'reqwest';

window.ajax = {
    get:function ( options ) {
        return reqwest({
            method:"get",
            url:this.getUrl(options.url),
            data:options.data
        });
    },

    getUrl:function ( url ) {
        let api = "https://cnodejs.org/api/v1";
        return api + url;
    },

    post:function ( options ) {
        return reqwest({
            method:"post",
            url:this.getUrl(options.url),
            data:options.data
        });
    }
};

window.getFormatTime = function ( time ) {
    if( !time ) return null;
    const currentTime = new Date().getTime();
    const oldTime = new Date(time).getTime();
    const diff = currentTime - oldTime;

   console.log( Math.floor(diff / 1000 / 60 / 60))


};